package com.yyh.synctool.client.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author xuan
 * @date 2021/12/10
 */
@Controller
public class PageController
{
    public static final String TEMPLATE_URL = "template/template";

    @GetMapping("/index")
    public String index(HttpServletRequest request) {
        return setAndReturn(request, "index.jsp", "首页");
    }

    @GetMapping("/taskSetting")
    public String syncTask(HttpServletRequest request) {
        return setAndReturn(request, "taskSetting.jsp", "同步任务");
    }

    @GetMapping("/management")
    public String management(HttpServletRequest request) {
        return setAndReturn(request, "management.jsp", "任务管理");
    }

    @GetMapping("/setting")
    public String setting(HttpServletRequest request) {
        return setAndReturn(request, "setting.jsp", "设置");
    }

    @GetMapping("/credential")
    public String credential(HttpServletRequest request) {
        return setAndReturn(request, "credential.jsp", "凭证管理");
    }

    private String setAndReturn(HttpServletRequest request, String view, String title) {
        request.setAttribute("view", view);
        request.setAttribute("title", title);
        return TEMPLATE_URL;
    }
}
